package com.buyhouse.zhaimao.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.buyhouse.zhaimao.R;

/**
 * 自定义横向菜单
 * 
 * @author zhouby
 *
 */
public class ButtonMenu extends RelativeLayout {

	/** 包裹的LinearLayout **/
	private LinearLayout mLn;
	/** 左侧图标 **/
	private ImageView mIv_left;
	/** 右侧图标 **/
	private ImageView mIv_right;
	/** 左侧标题 **/
	private TextView mTv_left;
	/** 右侧标题 （右侧图标左侧） **/
	private TextView mTv_right_one;
	/** 右侧标题（最右侧） **/
	private TextView mTv_right_two;

	public ButtonMenu(Context context) {
		super(context);
	}

	public ButtonMenu(Context context, AttributeSet attrs) {
		super(context, attrs);
		LayoutInflater layoutinflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		layoutinflater.inflate(R.layout.button_menu, this);
		initUI();
	}

	public ButtonMenu(Context context, AttributeSet attrs, int defStyleAttr) {
		super(context, attrs, defStyleAttr);
	}

	public ButtonMenu(Context context, AttributeSet attrs, int defStyleAttr,
			int defStyleRes) {
		super(context, attrs, defStyleAttr, defStyleRes);
	}

	private void initUI() {
		mIv_left = (ImageView) findViewById(R.id.iv_left);
		mIv_right = (ImageView) findViewById(R.id.iv_right);

		mTv_left = (TextView) findViewById(R.id.tv_left);
		mTv_right_one = (TextView) findViewById(R.id.tv_right_one);
		mTv_right_two = (TextView) findViewById(R.id.tv_right_two);

		mLn = (LinearLayout) findViewById(R.id.ln);
	}

	/**
	 * 设置左侧标题
	 * 
	 * @param text
	 */
	public void setTextLeft(String text) {
		mTv_left.setText(text);
	}
	/**
	 * 设置左侧标题颜色
	 * 
	 * @param text
	 */
	public void setColorLeft(int color){
		mTv_left.setTextColor(color);
	}
	

	/**
	 * 设置右侧标题一
	 * 
	 * @param text
	 */
	public void setTextRightOne(String text) {
		mTv_right_one.setText(text);
	}
	/**
	 * 设置右侧标题一颜色
	 * 
	 * @param text
	 */
	public void setColorRightOne(int color) {
		mTv_right_one.setTextColor(color);
	}

	/**
	 * 设置右侧标题二
	 * 
	 * @param text
	 */
	public void setTextRightTwo(String text) {
		mTv_right_two.setText(text);
	}

	/**
	 * 设置右侧标题二颜色
	 * 
	 * @param text
	 */
	public void setColorRightTwo(int color) {
		mTv_right_two.setTextColor(color);
	}

	/**
	 * 设置左侧图标
	 * 
	 * @param resid
	 */
	public void setImageLeft(int resid) {
		mIv_left.setBackgroundResource(resid);
	}

	/***
	 * 设置右侧图标
	 * 
	 * @param resid
	 *           
	 */
	public void setImageRight(int resid) {
		mIv_right.setBackgroundResource(resid);
	}

	/**
	 * 设置整个控件背景
	 * 
	 * @param resid
	 *            
	 */
	public void setMenuBg(int resid) {
		mLn.setBackgroundResource(resid);
	}
}
